package com.cmfi.dao;

import java.util.HashMap;
import java.util.List;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import com.cmfi.domain.PlateChainLineSpeed;

// TODO 添加@Mapper
@Mapper
public interface SpeedRecDao {
	@Select("SELECT lastDay AS dailyUsed, DATE_FORMAT(createTime, '%Y-%m-%d') AS date FROM tbl_speedrec ORDER BY date DESC LIMIT 7")
	List<HashMap<Object,String>> get7DaysUsed();
	
	@Select("SELECT SUM(lastDay) AS monthlyTotal, DATE_FORMAT(createTime, '%Y-%m') AS `year_month` FROM tbl_speedrec GROUP BY `year_month` ORDER BY `year_month`")
	List<HashMap<Object,String>> get12MonthsUsed();
	
    @Insert("insert into tbl_speedrec (id,value,lastDay,createTime) values(#{id},#{value},#{lastDay},#{createTime})")
    public int save(PlateChainLineSpeed speedRec);
}
